// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "InputAction.h"
#include "InputMappingContext.h"
#include "PlayerController2D.generated.h"


DECLARE_DELEGATE_TwoParams(FInputSignalDelegate, int32 Single, const FInputActionValue& Value);

/**
 * 
 */
UCLASS()
class PT001_API APlayerController2D : public APlayerController
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere)
	UInputAction* IA_Move;

	UPROPERTY(EditAnywhere)
	UInputAction* IA_Dash;

	UPROPERTY(EditAnywhere)
	UInputAction* IA_Jump;

	UPROPERTY(EditAnywhere)
	UInputAction* IA_Attack;
	
	UPROPERTY(EditAnywhere)
	UInputMappingContext* IMContext;


	UPROPERTY()
	class APlayer2D* PossessPlayer;

	UPROPERTY()
	class UStateMachine* StateMachine;

	// UPROPERTY()
	// class UIdleState* IdleState;
	//
	// UPROPERTY()
	// class UMoveState* MoveState;


	FInputSignalDelegate InputDelegate;

	void InitStateMachine();
public:
	APlayerController2D();
	
protected:
	virtual void BeginPlay() override;
	virtual void OnPossess(APawn* InPawn) override;
	virtual void SetupInputComponent() override;
	virtual void Tick(float DeltaTime) override;
	
	void OnMove(const FInputActionValue& Value);
	void OnMoveStart(const FInputActionValue& Value);
	void OnMoveStop(const FInputActionValue& Value);
	void OnDash(const FInputActionValue& Value);
	void OnJump(const FInputActionValue& Value);
	void OnAttack(const FInputActionValue& Value);
};


